﻿using System;
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using SsoaFramework.Core.Other;

namespace SsoaFramework.Core.Behaviors
{
    class ServiceTraceInspector : IClientMessageInspector 
    {
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            Guid guid = Guid.NewGuid();
            Log.Instance.Trace("[{0}] Sending service request", guid, channel.LocalAddress);
            return guid;
        }

        public void AfterReceiveReply(ref Message reply, object correlationState)
        {
            Log.Instance.Trace("[{0}] Received service reply", (Guid)correlationState);
        }
    }
}
